package com.jsh.erp.controller;

import com.jsh.common.api.vo.Result;
import com.jsh.common.system.vo.DictModel;
import com.jsh.common.util.SqlInjectionUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.client.RestTemplate;

import javax.servlet.http.HttpServletRequest;
import java.util.List;


/**
 * <p>
 * 字典表 前端控制器
 * </p>
 *
 * @Author zhangweijian
 * @since 2018-12-28
 */
@RestController
@RequestMapping("/sys/dict")
@Slf4j
public class DictController {


	@Autowired
	RestTemplate restTemplate;
	@Value("${URL.getDict}")
	String getForObject;

	/**
	 * 获取字典数据
	 * @param dictCode 字典code
	 * @param dictCode 表名,文本字段,code字段  | 举例：sys_user,realname,id
	 * @return
	 */
	@RequestMapping(value = "/getDictItems/{dictCode}")
	public Result<List<DictModel>> getDictItems(@PathVariable String dictCode) {

		Result forObject = restTemplate.getForObject(getForObject + "/" + dictCode, Result.class);


		return forObject;
	}

}
